#include<bits/stdc++.h>

using namespace std;

int a[100];
int ret[100];
int mn = 0;
void dfs(int now,int n){
	if(now >  n){
		int mmm =0;
		for(int i = 1;i <= n;i++){
			
			for(int j = i - 1;j >= 1;j--){
				if(ret[i] == ret[j]){
					if(a[i] == a[j]){
						mmm += a[i];
					}
					break;
				}
				
			}

		}
		mn = max(mn,mmm);		
		return;
	}
	
	ret[now] = 1;
	dfs(now+1,n);
	ret[now] = 2;
	dfs(now+1,n);
}
int main(){
	
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		//for(int i = 1;i <= n;i++){
			//cin>>a[i];
		//}
		//dfs(1,n);
		cout<<mn<<endl;;
		mn = 0;
	}
	fclose(stdin);
	fclose(stdout);
	
	return 0;
}
